# eric7.UI.Previewers.PreviewerHTML

Module implementing a previewer widget for HTML, Markdown and ReST files.

### Global Attributes

None

### Classes

PreviewProcessingThread | Class implementing a thread to process some text into HTML usable by the previewer view.
PreviewerHTML | Class implementing a previewer widget for HTML, Markdown and ReST files.

### Functions

None

## PreviewProcessingThread

Class implementing a thread to process some text into HTML usable by the previewer view.

### Signals

htmlReady(str, str, str)
  emitted with the file name, the processed HTML and the web site root path to signal the availability of the processed HTML

### Derived from

QThread

### Class Attributes

None

### Class Methods

None

### Methods

PreviewProcessingThread | Constructor
__convertMarkdown | Private method to convert Markdown text into HTML.
__convertReST | Private method to convert ReST text into HTML.
__convertReSTDocutils | Private method to convert ReST text into HTML using 'docutils'.
__convertReSTSphinx | Private method to convert ReST text into HTML using 'sphinx'.
__getHtml | Private method to process the given text depending upon the given language.
__processRootPath | Private method to adjust absolute references to the given root path.
__processSSI | Private method to process the given text for SSI statements.
process | Public method to convert the given text to HTML.
run | Public thread method to convert the stored data.

### Static Methods

None

#### PreviewProcessingThread (Constructor)

PreviewProcessingThread(parent=None)

Constructor

parent (QObject)
  reference to the parent object

#### PreviewProcessingThread.__convertMarkdown

__convertMarkdown(text, convertNewLineToBreak, usePyMdownExtensions, htmlFormat)

Private method to convert Markdown text into HTML.

text (str)
  text to be processed
convertNewLineToBreak (bool)
  flag indicating to convert new lines to HTML break (Markdown only)
usePyMdownExtensions (bool)
  flag indicating to enable the PyMdown extensions, if they are available
htmlFormat (str)
  HTML format to be generated by markdown

Return:
  processed HTML

Return Type:
  str

#### PreviewProcessingThread.__convertReST

__convertReST(text, useSphinx, restDocutilsHtmlFormat)

Private method to convert ReST text into HTML.

text (str)
  text to be processed
useSphinx (bool)
  flag indicating to use Sphinx to generate the ReST preview
restDocutilsHtmlFormat (str)
  HTML format to be generated by docutils

Return:
  processed HTML

Return Type:
  str

#### PreviewProcessingThread.__convertReSTDocutils

__convertReSTDocutils(text, htmlFormat)

Private method to convert ReST text into HTML using 'docutils'.

text (str)
  text to be processed
htmlFormat (str)
  HTML format to be generated

Return:
  processed HTML

Return Type:
  str

#### PreviewProcessingThread.__convertReSTSphinx

__convertReSTSphinx(text)

Private method to convert ReST text into HTML using 'sphinx'.

text (str)
  text to be processed

Return:
  processed HTML

Return Type:
  str

#### PreviewProcessingThread.__getHtml

__getHtml(language, text, ssiEnabled, filePath, rootPath, useSphinx, convertNewLineToBreak, usePyMdownExtensions, markdownHtmlFormat, restDocutilsHtmlFormat, )

Private method to process the given text depending upon the given language.

language (str)
  language of the text
text (str)
  to be processed
ssiEnabled (bool)
  flag indicating to do some (limited) SSI processing
filePath (str)
  file path of the text
rootPath (str)
  root path to be used for SSI processing
useSphinx (bool)
  flag indicating to use Sphinx to generate the ReST preview
convertNewLineToBreak (bool)
  flag indicating to convert new lines to HTML break (Markdown only)
usePyMdownExtensions (bool)
  flag indicating to enable the PyMdown extensions, if they are available
markdownHtmlFormat (str)
  HTML format to be generated by markdown
restDocutilsHtmlFormat (str)
  HTML format to be generated by docutils

Return:
  processed HTML text

Return Type:
  str

#### PreviewProcessingThread.__processRootPath

__processRootPath(txt, root)

Private method to adjust absolute references to the given root path.

txt (str)
  text to be processed
root (str)
  directory of the document root

Return:
  processed HTML

Return Type:
  str

#### PreviewProcessingThread.__processSSI

__processSSI(txt, filename, root)

Private method to process the given text for SSI statements.

Note: Only a limited subset of SSI statements are supported.

txt (str)
  text to be processed
filename (str)
  name of the file associated with the given text
root (str)
  directory of the document root

Return:
  processed HTML

Return Type:
  str

#### PreviewProcessingThread.process

process(filePath, language, text, ssiEnabled, rootPath, useSphinx, convertNewLineToBreak, usePyMdownExtensions, markdownHtmlFormat, restDocutilsHtmlFormat, )

Public method to convert the given text to HTML.

filePath (str)
  file path of the text
language (str)
  language of the text
text (str)
  text to be processed
ssiEnabled (bool)
  flag indicating to do some (limited) SSI processing
rootPath (str)
  root path to be used for SSI processing
useSphinx (bool)
  flag indicating to use Sphinx to generate the ReST preview
convertNewLineToBreak (bool)
  flag indicating to convert new lines to HTML break (Markdown only)
usePyMdownExtensions (bool)
  flag indicating to enable the PyMdown extensions, if they are available
markdownHtmlFormat (str)
  HTML format to be generated by markdown
restDocutilsHtmlFormat (str)
  HTML format to be generated by docutils

#### PreviewProcessingThread.run

run()

Public thread method to convert the stored data.

Up

## PreviewerHTML

Class implementing a previewer widget for HTML, Markdown and ReST files.

### Derived from

QWidget

### Class Attributes

None

### Class Methods

None

### Methods

PreviewerHTML | Constructor
__execJavaScript | Private function to execute a JavaScript function Synchroneously.
__restoreScrollBarPositions | Private method to restore scroll bar positions for a previewed editor.
__saveScrollBarPositions | Private method to save scroll bar positions for a previewed editor.
__setHtml | Private method to set the HTML to the view and restore the scroll bars positions.
__showLink | Private slot to show the hovered link in a tooltip.
on_htmlButton_clicked | Private slot to copy the HTML contents to the clipboard.
on_previewView_titleChanged | Private slot to handle a change of the title.
on_ssiCheckBox_clicked | Private slot to enable/disable SSI.
processEditor | Public slot to process an editor's text.
resultCallback |
shutdown | Public method to perform shutdown actions.

### Static Methods

None

#### PreviewerHTML (Constructor)

PreviewerHTML(parent=None)

Constructor

parent (QWidget)
  reference to the parent widget

#### PreviewerHTML.__execJavaScript

__execJavaScript(script)

Private function to execute a JavaScript function Synchroneously.

script (str)
  JavaScript script source to be executed

Return:
  result of the script

Return Type:
  depending upon script result

#### PreviewerHTML.__restoreScrollBarPositions

__restoreScrollBarPositions()

Private method to restore scroll bar positions for a previewed editor.

#### PreviewerHTML.__saveScrollBarPositions

__saveScrollBarPositions()

Private method to save scroll bar positions for a previewed editor.

#### PreviewerHTML.__setHtml

__setHtml(filePath, html, rootPath)

Private method to set the HTML to the view and restore the scroll bars positions.

filePath (str)
  file path of the previewed editor
html (str)
  processed HTML text ready to be shown
rootPath (str)
  path of the web site root

#### PreviewerHTML.__showLink

__showLink(urlStr)

Private slot to show the hovered link in a tooltip.

urlStr (str)
  hovered URL

#### PreviewerHTML.on_htmlButton_clicked

on_htmlButton_clicked()

Private slot to copy the HTML contents to the clipboard.

#### PreviewerHTML.on_previewView_titleChanged

on_previewView_titleChanged(title)

Private slot to handle a change of the title.

title (str)
  new title

#### PreviewerHTML.on_ssiCheckBox_clicked

on_ssiCheckBox_clicked(checked)

Private slot to enable/disable SSI.

checked (bool)
  state of the checkbox

#### PreviewerHTML.processEditor

processEditor(editor=None)

Public slot to process an editor's text.

editor (Editor)
  editor to be processed

#### PreviewerHTML.resultCallback

resultCallback(resDict=resultDict)

#### PreviewerHTML.shutdown

shutdown()

Public method to perform shutdown actions.

Up